# for Topic 8a # first get our two sets of values x <- c( 10, 19, 15, 10, 7, 5) # y <- c( 27, 32, 33, 19, 25, 20) # get a generic plot plot(x,y) # then make a much better plot plot(x,y, main="Data for Topic 8a", xlim=c(-1,21), ylim=c(-1,39), las=1, xlab="x axis", ylab="y axis", xaxp=c(0,20,10), yaxp=c(0,40,8), pch=19, col="red") abline(v=0,h=0) abline(v=seq(2,20,2), h=seq(5,40,5), lty="dotted", col="darkgreen") # draw the line through (6,18) and (20,35) abline(25/2, 5/4, col="blue", lty="dashed") m <- 5/4 c <- 25/2 diffoe <- y - (m*x+c) diffoe sum( diffoe^2) cor(x,y) lm(y~x)